import redis
from abc import ABC, abstractmethod
from threading import Lock,Thread
from time import sleep

# 定义生产者和消费者多线程方法
class Runner(ABC):
    def __init__(self,redis_pool:redis.ConnectionPool):
        self.redis_pool = redis_pool
    
    def get_conn(self):
        self.redis_conn = redis.Redis(connection_pool=self.redis_pool)
            
    @abstractmethod
    def producter(self):
        pass
    
    @abstractmethod
    def consumer(self):
        pass
    
    def run(self):
        c = Thread(target=self.consumer)
        c.setDaemon(True)
        c.start()
        sleep(1)
        self.producter()
        